@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* AWS Color Palette */
    --aws-navy: #232f3e;
    --aws-orange: #ff9900;
    --aws-orange-hover: #ec7211;
    --aws-gray-900: #16191f;
    --aws-gray-700: #414d5c;
    --aws-gray-400: #879596;
    --aws-gray-200: #eaeded;
    --aws-gray-100: #f2f3f3;
    --aws-blue: #0073bb;
    --aws-blue-soft: rgba(0, 115, 187, 0.05);
    --aws-blue-outline: rgba(0, 115, 187, 0.2);
    --aws-orange: #ff9900;
    --aws-orange-soft: rgba(255, 153, 0, 0.1);
    --aws-orange-hover: #ec7211;
    --aws-white: #ffffff;
    --aws-gray-50: #fbfbfb;
    
    --primary: var(--aws-orange);
    --primary-hover: var(--aws-orange-hover);
    --bg-main: #f8f9fa;
    --card-bg: var(--aws-white);
    --text-main: var(--aws-gray-900);
    --text-muted: var(--aws-gray-700);
    --border: var(--aws-gray-400);
    --light-border: var(--aws-gray-200);
    --success: #1d8102;
    --success-soft: rgba(29, 129, 2, 0.1);
    --error: #d13212;
    --error-soft: rgba(209, 50, 18, 0.1);
    --shadow-sm: 0 1px 1px 0 rgba(0, 28, 36, 0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* AWS-like Top Navigation (Global Header) */
.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--aws-navy);
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo::before {
    content: "☁️";
}

/* Glass Card removed for AWS feel */
.card {
    background: var(--card-bg);
    border: 1px solid var(--light-border);
    border-radius: 4px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.section-title {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--light-border);
}

.section-title h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--aws-navy);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Auth / Simple Forms */
.auth-container {
    max-width: 440px;
    margin: 10vh auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--aws-gray-900);
    font-size: 0.875rem;
    font-weight: 600;
}

input, select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--aws-white);
    border: 1px solid var(--aws-gray-400);
    border-radius: 2px;
    color: var(--text-main);
    font-size: 0.875rem;
}

input:focus {
    outline: none;
    border-color: var(--aws-blue);
    box-shadow: 0 0 0 1px var(--aws-blue);
}

.btn {
    display: inline-block;
    padding: 0.45rem 1.25rem;
    border-radius: 2px;
    font-weight: 700;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.1s;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--aws-orange);
    color: var(--aws-navy);
    border-color: var(--aws-orange);
}

.btn-primary:hover {
    background: var(--aws-orange-hover);
    border-color: var(--aws-orange-hover);
}

.btn-outline {
    background: var(--aws-white);
    border: 1px solid var(--aws-gray-700);
    color: var(--aws-gray-900);
}

.btn-outline:hover {
    background: var(--aws-gray-100);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

/* Dashboard Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.status-badge {
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-active { background: #dff6dd; color: #1d8102; border: 1px solid #1d8102; }
.status-inactive { background: #fdf3f1; color: #d13212; border: 1px solid #d13212; }

/* Rules List */
.item-list {
    margin-top: 1rem;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--light-border);
}

.item-row:hover {
    background: var(--aws-gray-100);
}

.item-row:last-child {
    border-bottom: none;
}

.footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--aws-gray-400);
    font-size: 0.75rem;
    padding-bottom: 2rem;
}

/* Sidebar Layout */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--aws-white);
    border-right: 1px solid var(--light-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar-header {
    background: var(--aws-navy);
    color: white;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-search {
    padding: 0.75rem 0.5rem;
    background: var(--aws-white);
    border-bottom: 1px solid var(--aws-gray-100);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 0.75rem;
    font-size: 0.85rem;
    color: var(--aws-gray-400);
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    background: var(--aws-gray-100);
    border: 1px solid var(--aws-gray-200);
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.search-input-wrapper input:focus {
    background: var(--aws-white);
    box-shadow: 0 0 0 1px var(--aws-blue);
    border-color: var(--aws-blue);
}

.sidebar.collapsed .sidebar-search {
    display: none;
}

.sidebar-brand {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.02rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s, max-width 0.25s;
    max-width: 160px;
}

.sidebar.collapsed .sidebar-brand {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--aws-gray-400);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    color: white;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.menu-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--aws-gray-400);
    padding: 1.25rem 1.25rem 0.5rem;
    cursor: default;
}

.sidebar.collapsed .menu-section-title {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.menu-item {
    margin: 1px 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--aws-gray-700);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.menu-link:hover {
    background: var(--aws-gray-100);
    color: var(--aws-navy);
}

.menu-link.active {
    background: var(--aws-blue-soft);
    color: var(--aws-blue);
    border-left-color: var(--aws-blue);
    font-weight: 600;
}

.menu-link i {
    min-width: 24px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
    text-align: center;
    opacity: 0.8;
}

.menu-link.active i {
    opacity: 1;
}

.sidebar.collapsed .menu-link span {
    display: none;
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--light-border);
    background: var(--aws-gray-50);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed + .main-content {
    margin-left: 64px;
}

.dashboard-header {
    background: var(--aws-white);
    border-bottom: 1px solid var(--light-border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Icon-only action button (Amazon console style) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 2px;
    background: var(--aws-white);
    border: 1px solid var(--aws-gray-400);
    color: var(--aws-gray-700);
    cursor: pointer;
    transition: all 0.1s;
    font-size: 0.85rem;
    text-decoration: none;
    flex-shrink: 0;
}
.btn-icon:hover {
    background: var(--aws-gray-100);
    border-color: var(--aws-navy);
    color: var(--aws-navy);
}
.btn-icon.danger {
    color: var(--error);
    border-color: rgba(209, 50, 18, 0.3);
}
.btn-icon.danger:hover {
    background: var(--error-soft);
    border-color: var(--error);
}
.btn-icon.warning {
    color: var(--aws-orange-hover);
    border-color: rgba(255, 153, 0, 0.3);
}
.btn-icon.warning:hover {
    background: var(--aws-orange-soft);
    border-color: var(--aws-orange-hover);
}
.btn-icon.success {
    color: var(--success);
    border-color: rgba(29, 129, 2, 0.3);
}
.btn-icon.success:hover {
    background: var(--success-soft);
    border-color: var(--success);
}

.dashboard-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--aws-navy);
}

.content-inner {
    padding: 0 1.5rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 7, 22, 0.45);
    backdrop-filter: blur(2px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    max-width: 550px;
    width: 90%;
    background: var(--aws-white);
    padding: 2.5rem;
    border-radius: 4px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--light-border);
    color: var(--text-main);
    position: relative;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal h3 {
    margin-bottom: 1rem;
    color: var(--aws-navy);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--light-border);
    margin-top: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem;
    background: var(--aws-white);
    border: 1px solid var(--light-border);
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--aws-navy);
    color: var(--aws-white);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-details {
    overflow: hidden;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--aws-navy);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    line-height: 1.2;
}

.user-role {
    display: block;
    font-size: 0.7rem;
    color: var(--aws-gray-400);
    line-height: 1.2;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--aws-gray-400);
    color: var(--aws-gray-700);
    border-radius: 2px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.1s ease;
}

.logout-btn:hover {
    background: var(--aws-gray-100);
    border-color: var(--aws-gray-700);
    color: var(--aws-navy);
}

.sidebar.collapsed .user-profile {
    padding: 0.4rem;
    justify-content: center;
    border: none;
    background: transparent;
}

.sidebar.collapsed .user-details, 
.sidebar.collapsed .logout-btn span {
    display: none;
}

.sidebar.collapsed .logout-btn {
    padding: 0.5rem 0;
    border: none;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--aws-gray-400);
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--success);
}

/* AI Status Colors */
.bg-danger  { background-color: #ef4444 !important; }
.bg-warning { background-color: #f59e0b !important; }
.bg-success { background-color: #22c55e !important; }
.bg-info    { background-color: var(--aws-blue) !important; }

/* Stats Components */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.stat-card {
    background: var(--aws-white);
    border: 1px solid var(--aws-gray-200);
    border-radius: 4px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--aws-navy);
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--aws-gray-400);
}

/* Breadcrumb styling */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.breadcrumb a {
    color: var(--aws-blue);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: var(--aws-gray-400);
}

.breadcrumb i {
    color: var(--aws-gray-200);
    font-size: 0.7rem;
}
