:root {
    color-scheme: dark;
    --bg: #0b1220;
    --bg-soft: rgba(15, 23, 42, 0.8);
    --card: rgba(15, 23, 42, 0.84);
    --border: rgba(148, 163, 184, 0.25);
    --accent: #38bdf8;
    --accent-strong: #60a5fa;
    --fg: #f8fafc;
    --muted: rgba(226, 232, 240, 0.72);
    --danger: #f87171;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Light mode */
[data-theme="light"] {
    color-scheme: light;
    --bg: #f8fafc;
    --bg-soft: rgba(241, 245, 249, 0.8);
    --card: #ffffff;
    --border: rgba(148, 163, 184, 0.3);
    --accent: #0ea5e9;
    --accent-strong: #0284c7;
    --fg: #0f172a;
    --muted: rgba(15, 23, 42, 0.65);
    --danger: #dc2626;
}

[data-theme="light"] body {
    background: radial-gradient(circle at top left, rgba(14, 165, 233, 0.08), transparent 45%),
                radial-gradient(circle at bottom right, rgba(250, 204, 21, 0.06), transparent 45%),
                var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 45%),
                radial-gradient(circle at bottom right, rgba(250, 204, 21, 0.12), transparent 45%),
                var(--bg);
    color: var(--fg);
    padding: clamp(16px, 4vw, 32px);
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 24px);
}

header.panel-header {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.brand strong {
    font-size: 1.4rem;
}

.brand span {
    color: var(--muted);
    font-size: 0.94rem;
}

nav.panel-nav {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(148, 163, 184, 0.6);
    padding: 0 4px;
    margin-bottom: 4px;
}

[data-theme="light"] .nav-group-label {
    color: rgba(15, 23, 42, 0.5);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

nav.panel-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.7);
    color: var(--fg);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    transition: transform 0.18s ease, border 0.18s ease, box-shadow 0.18s ease, opacity 0.15s ease;
    white-space: nowrap;
    position: relative;
}

[data-theme="light"] nav.panel-nav a {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(148, 163, 184, 0.3);
}

nav.panel-nav a:is(:hover, :focus-visible) {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: 0 16px 32px rgba(56, 189, 248, 0.28);
}

[data-theme="light"] nav.panel-nav a:is(:hover, :focus-visible) {
    box-shadow: 0 16px 32px rgba(14, 165, 233, 0.2);
}

nav.panel-nav a.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0f172a;
    border-color: rgba(148, 216, 248, 0.45);
    box-shadow: 0 18px 36px rgba(56, 189, 248, 0.34);
}

[data-theme="light"] nav.panel-nav a.active {
    color: #ffffff;
}

.panel-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.24);
}

[data-theme="light"] .panel-user {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(148, 163, 184, 0.3);
}

.panel-user strong {
    font-size: 0.95rem;
}

.panel-user span {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
}

.panel-user-actions {
    display: flex;
    gap: 8px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    padding: 0;
}

[data-theme="light"] .theme-toggle {
    background: rgba(241, 245, 249, 0.8);
}

.theme-toggle:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent);
    transform: scale(1.05);
}

[data-theme="light"] .theme-toggle:hover {
    background: rgba(14, 165, 233, 0.1);
}

.panel-user-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.75);
    color: var(--fg);
    text-decoration: none;
    font-size: 1.1rem;
}

[data-theme="light"] .panel-user-actions a {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(148, 163, 184, 0.3);
}

.panel-user-actions a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

[data-theme="light"] .panel-user-actions a:hover {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--accent);
}

main.panel-main {
    display: grid;
    gap: clamp(16px, 3vw, 24px);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: clamp(20px, 4vw, 28px);
    box-shadow: 0 28px 48px rgba(8, 47, 73, 0.45);
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

table thead {
    background: rgba(148, 163, 184, 0.12);
}

table th, table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

table tr:last-child td {
    border-bottom: none;
}

table th {
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    color: rgba(226, 232, 240, 0.85);
}

table td {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.86);
}

.table-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.72);
    color: var(--fg);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.92rem;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border 0.16s ease;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 16px 28px rgba(56, 189, 248, 0.25);
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0b172b;
    border-color: rgba(148, 216, 248, 0.4);
    box-shadow: 0 20px 36px rgba(56, 189, 248, 0.34);
}

.btn.danger {
    border-color: rgba(248, 113, 113, 0.32);
    color: #fecaca;
}

.btn.danger:hover {
    color: #fee2e2;
    border-color: rgba(248, 113, 113, 0.55);
    box-shadow: 0 18px 32px rgba(248, 113, 113, 0.28);
}

form fieldset {
    border: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 16px;
}

label.form-control {
    display: grid;
    gap: 8px;
}

label.form-control span {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.82);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.6);
    color: var(--fg);
    font-size: 0.92rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(56, 189, 248, 0.18);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge.danger {
    background: rgba(248, 113, 113, 0.18);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.3);
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid.three {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

@media (min-width: 1024px) {
    .grid.three {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .grid.three {
        grid-template-columns: 1fr;
    }
}

.panel-footer {
    text-align: center;
    font-size: 0.88rem;
    color: var(--muted);
    padding: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    border: 1px solid rgba(252, 165, 165, 0.3);
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
}

.alert.success {
    border-color: rgba(134, 239, 172, 0.3);
    background: rgba(34, 197, 94, 0.18);
    color: #bbf7d0;
}

.loading {
    text-align: center;
    padding: 24px;
    color: var(--muted);
}

/* Page Transition Animations */
body {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Page Transition Overlay */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-transition-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.page-transition-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Smooth navigation link hover effect */
nav.panel-nav a::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

nav.panel-nav a:hover::before {
    opacity: 1;
}

/* Prevent flash on page load */
main.panel-main {
    animation: slideInUp 0.25s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        padding: 12px;
        gap: 12px;
    }

    /* Header adjustments */
    header.panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .brand {
        order: 1;
    }

    .brand strong {
        font-size: 1.2rem;
    }

    .brand span {
        font-size: 0.85rem;
    }

    /* Navigation - Mobile friendly */
    nav.panel-nav {
        order: 3;
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }

    .nav-group {
        width: 100%;
    }

    .nav-group-items {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    nav.panel-nav a {
        padding: 12px 16px;
        font-size: 0.9rem;
        justify-content: center;
        white-space: normal;
        text-align: center;
        min-height: 48px; /* Larger touch target */
        width: 100%;
    }

    /* User panel - Mobile */
    .panel-user {
        order: 2;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .panel-user > div:first-child {
        text-align: center;
    }

    .panel-user-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Cards */
    .card {
        padding: 16px;
        border-radius: 16px;
    }

    /* Tables - Mobile scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
        border-radius: 12px;
    }

    table {
        min-width: 600px;
        font-size: 0.85rem;
    }

    table th, table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
    
    /* Table actions column - stack buttons on mobile */
    table thead th:last-child {
        position: sticky;
        right: 16px;
        z-index: 11;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    }
    table td:last-child {
        white-space: nowrap;
        position: sticky;
        right: 16px;
        background: var(--card) !important;
        z-index: 10;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    }
    
    table td:last-child .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        margin: 0;
        white-space: nowrap;
    }

    /* Buttons - Larger touch targets */
    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        min-height: 44px;
        justify-content: center;
        width: 100%;
    }
    
    /* Button groups - stack on mobile */
    .btn-group,
    div[style*="display: flex"][style*="gap"] {
        flex-direction: column;
    }
    
    .btn-group .btn,
    div[style*="display: flex"][style*="gap"] .btn {
        width: 100%;
        margin: 4px 0;
    }

    /* Forms */
    label.form-control {
        gap: 6px;
    }

    label.form-control span {
        font-size: 0.85rem;
    }

    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Prevent zoom on input focus (iOS) */
    @supports (-webkit-touch-callout: none) {
        input[type="text"],
        input[type="password"],
        input[type="number"],
        input[type="email"],
        select,
        textarea {
            font-size: 16px;
        }
    }

    /* Grid layouts */
    .grid.two {
        grid-template-columns: 1fr;
    }
    
    .grid.three {
        grid-template-columns: 1fr !important;
    }

    .filters-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Dashboard stat cards */
    .card strong {
        font-size: 1.5rem !important;
    }
    
    .card span {
        font-size: 0.85rem !important;
    }

    /* Modal adjustments */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        max-width: 100% !important;
        width: 100% !important;
        padding: 20px;
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        margin: 0;
    }
    
    .modal h3 {
        font-size: 1.2rem;
    }
    
    /* Form controls in modal */
    .modal .form-control {
        margin-bottom: 16px;
    }
    
    .modal .permissions-grid {
        grid-template-columns: 1fr;
    }
    
    /* Modal form buttons */
    .modal form fieldset > div[style*="display: flex"],
    .modal form > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .modal form fieldset > div[style*="display: flex"] .btn,
    .modal form > div[style*="display: flex"] .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Textarea in modal */
    .modal textarea {
        min-height: 120px;
        resize: vertical;
    }

    /* Bulk actions */
    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .bulk-actions > div {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 6px;
    }

    .pagination button {
        padding: 10px 12px;
        min-height: 44px;
    }

    /* Group cards (mail lists) */
    .groups-container {
        grid-template-columns: 1fr;
    }

    .group-card {
        padding: 16px;
    }

    .group-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .group-header button {
        width: 100%;
    }

    /* Email items */
    .email-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .email-item button {
        width: 100%;
    }

    /* Table actions */
    .table-actions {
        flex-direction: column;
        gap: 6px;
        min-width: 80px;
    }

    .table-actions .btn {
        width: 100%;
        white-space: nowrap;
    }

    /* Card grids (retweet links, etc.) */
    .links-grid {
        grid-template-columns: 1fr !important;
    }

    .link-card {
        padding: 14px;
    }

    .link-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .link-card-actions {
        flex-direction: column;
        width: 100%;
    }

    .link-card-actions button {
        width: 100%;
    }
    
    /* Filters - stack on mobile */
    .filters {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .filters > * {
        width: 100%;
        min-width: auto !important;
    }
    
    /* Section headers with buttons */
    section .card > div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    section .card > div[style*="display: flex"][style*="justify-content: space-between"] button {
        width: 100%;
    }
    
    /* Quick access cards */
    .quick-access-card {
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    /* Text overflow */
    h2, h3 {
        word-break: break-word;
        hyphens: auto;
    }
    
    /* Card content spacing */
    .card > * {
        margin-bottom: 12px;
    }
    
    .card > *:last-child {
        margin-bottom: 0;
    }
    
    /* Touch-friendly interactions */
    a, button {
        -webkit-tap-highlight-color: rgba(56, 189, 248, 0.2);
    }
    
    /* Better scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Header improvements */
    header.panel-header {
        gap: 12px;
    }
    
    /* Footer */
    .panel-footer {
        font-size: 0.8rem;
        padding: 12px;
        text-align: center;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }
    
    main.panel-main {
        width: 100%;
        max-width: 100%;
    }
    
    /* Card improvements */
    .card h2 {
        font-size: 1.3rem;
        line-height: 1.3;
    }
    
    .card p {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    body {
        padding: 8px;
        gap: 10px;
    }

    .card {
        padding: 12px;
        border-radius: 12px;
    }
    
    .card strong {
        font-size: 1.3rem !important;
    }

    .brand strong {
        font-size: 1.1rem;
    }

    nav.panel-nav a {
        font-size: 0.85rem;
        padding: 10px 14px;
        min-height: 44px;
    }

    .nav-group-items {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 500px;
        font-size: 0.8rem;
    }

    table th, table td {
        padding: 8px 6px;
        font-size: 0.8rem;
    }
    
    table th {
        font-size: 0.75rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .modal {
        padding: 16px;
        border-radius: 16px 16px 0 0;
    }
    
    .modal h3 {
        font-size: 1.1rem;
    }
    
    /* Dashboard cards */
    .grid.three .card {
        padding: 16px;
    }
    
    .grid.three .card strong {
        font-size: 1.4rem !important;
    }
    
    /* Hızlı erişim kartları */
    .grid.two .card {
        padding: 16px;
    }
    
    .grid.two .card h3 {
        font-size: 1.1rem;
    }
    
    .grid.two .card p {
        font-size: 0.85rem;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .modal {
        max-height: 85vh;
        border-radius: 16px;
    }
    
    .modal-overlay {
        align-items: center;
        padding: 12px;
    }

    nav.panel-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav-group-items {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid.three {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .grid.two {
        grid-template-columns: repeat(2, 1fr);
    }
}

