/* ==============================================
   MODERN MOBILE APP STYLE CSS
   Fully responsive, touch-optimized, glassmorphic UI
   Works with existing HTML structure - no changes needed
   ============================================== */

/* ---------- RESET & BASE ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* iOS-style smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(145deg, #f5f7fc 0%, #eef2f9 100%);
    color: #1a1e2b;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Custom scrollbar for modern look */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

/* ---------- TYPOGRAPHY & LINKS ---------- */
a {
    text-decoration: none;
    color: #f59e0b;
    transition: all 0.2s ease;
}

/* ---------- APP LAYOUT (MOBILE FIRST APPROACH) ---------- */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* SIDEBAR TRANSFORMS INTO BOTTOM NAVIGATION BAR ON MOBILE */
.sidebar {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
    padding: 12px 16px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    z-index: 1000;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    border: none;
    overflow-y: visible;
    height: auto;
    top: auto;
}

/* Hide sidebar heading on mobile */
.sidebar h2 {
    display: none;
}

/* Bottom nav links - app style */
.sidebar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 6px;
    border-radius: 32px;
    margin: 0;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    flex: 1;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    position: relative;
    gap: 4px;
}

/* Add simple icons using pseudo-elements (emojis for app feel) */
.sidebar a::before {
    content: "●";
    font-size: 20px;
    font-weight: normal;
    opacity: 0.7;
    display: block;
    line-height: 1;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
}

/* Custom icons based on link text (approximate mapping) */
.sidebar a:first-child::before { content: "🏠"; }
.sidebar a:nth-child(2)::before { content: "📊"; }
.sidebar a:nth-child(3)::before { content: "📷"; }
.sidebar a:nth-child(4)::before { content: "📝"; }
.sidebar a:nth-child(5)::before { content: "👤"; }
.sidebar a:last-child::before { content: "⚙️"; }

/* Active/current page styling (simulate active state) */
.sidebar a:active,
.sidebar a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.sidebar a:active::before {
    transform: scale(1.1);
}

/* Main content area - adjusted for bottom bar */
.main {
    flex: 1;
    padding: 20px 16px 90px 16px;
    width: 100%;
    background: transparent;
}

/* ---------- PAGE HEADER (APP-LIKE) ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 8px 0;
}

.page-head h1, .page-head h2 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #1e293b, #2d3a4e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.3px;
}

/* ---------- MODERN CARD GRID (MOBILE OPTIMIZED) ---------- */
.cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* Glassmorphic cards */
.card,
.form-card,
.table-wrap,
.login-card,
.detail-card,
.photo-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.25s ease;
}

.card {
    padding: 20px;
}

.card h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #5b6e8c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.card p {
    margin: 0;
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(145deg, #1e293b, #334155);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Interactive card hover effect (desktop) + active touch effect */
.card:active {
    transform: scale(0.98);
}

/* ---------- FORM STYLES (MOBILE FRIENDLY) ---------- */
.form-card,
.detail-card,
.table-wrap {
    padding: 22px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1e293b;
    font-size: 15px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    padding: 14px 16px;
    font-size: 16px;
    background: #ffffff;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.form-group textarea {
    min-height: 110px;
    resize: vertical;
}

/* Form row for desktop, but stays responsive */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* ---------- BUTTONS (TOUCH FRIENDLY, LARGE TAP TARGET) ---------- */
.btn {
    display: inline-block;
    background: linear-gradient(105deg, #f59e0b, #d97706);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
    text-align: center;
    letter-spacing: 0.3px;
    width: 100%;
}

.btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.4);
}

/* Alert / snackbar style */
.alert {
    padding: 14px 18px;
    border-radius: 24px;
    margin-bottom: 20px;
    backdrop-filter: blur(8px);
    font-weight: 500;
}

.alert.success {
    background: rgba(34, 197, 94, 0.15);
    color: #166534;
    border-left: 4px solid #22c55e;
}

.alert.error {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border-left: 4px solid #ef4444;
}

/* ---------- TABLE (HORIZONTAL SCROLL FOR MOBILE) ---------- */
.table-wrap {
    overflow-x: auto;
    border-radius: 28px;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 500px;
}

table th,
table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    text-align: left;
    vertical-align: middle;
}

table th {
    background: rgba(241, 245, 249, 0.7);
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
}

table tr:last-child td {
    border-bottom: none;
}

/* ---------- LOGIN CARD (CENTERED MODAL STYLE) ---------- */
.login-wrap {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(145deg, #eef2ff, #e2e8f0);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 24px;
    border-radius: 48px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ---------- PHOTO GRID (MOBILE FIRST) ---------- */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.photo-card {
    overflow: hidden;
    border-radius: 28px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.photo-card:active {
    transform: scale(0.98);
}

.photo-card img {
    width: 100%;
    height: 210px;
    object-fit: cover;
    display: block;
}

.photo-card-body {
    padding: 16px;
}

/* ---------- UTILITIES & ENHANCEMENTS ---------- */
/* Floating action button feel for main action */
.page-head .btn {
    width: auto;
    padding: 10px 20px;
    font-size: 14px;
}

/* Touch-friendly spacing for all interactive elements */
button, a, .btn, [role="button"] {
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========== DESKTOP & TABLET LAYOUT (BREAKPOINT 768px) ========== */
@media (min-width: 768px) {
    /* Restore sidebar as left navigation */
    .app {
        flex-direction: row;
    }

    .sidebar {
        position: sticky;
        top: 0;
        left: 0;
        right: auto;
        bottom: auto;
        width: 280px;
        height: 100vh;
        background: linear-gradient(180deg, #0f172a, #1e293b);
        backdrop-filter: none;
        border-radius: 0;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 28px 20px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
        border-top-right-radius: 0;
    }

    .sidebar h2 {
        display: block;
        font-size: 24px;
        margin-bottom: 32px;
        font-weight: 700;
        letter-spacing: -0.5px;
        padding-left: 8px;
        color: #f59e0b;
    }

    .sidebar a {
        flex-direction: row;
        justify-content: flex-start;
        gap: 14px;
        background: rgba(255, 255, 255, 0.06);
        margin-bottom: 10px;
        padding: 12px 16px;
        font-size: 15px;
        color: rgba(255, 255, 255, 0.85);
    }

    .sidebar a::before {
        font-size: 20px;
        margin-bottom: 0;
        opacity: 0.9;
    }

    .sidebar a:hover {
        background: rgba(245, 158, 11, 0.2);
        transform: translateX(4px);
    }

    .main {
        padding: 28px 32px 32px 32px;
    }

    /* Desktop grid improvements */
    .cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }

    .form-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .btn {
        width: auto;
        padding: 12px 28px;
    }

    .photo-card img {
        height: 240px;
    }
    
    /* Hover effects only on desktop */
    .card:hover,
    .photo-card:hover,
    .form-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.12);
    }
}

/* ========== SMALL PHONES (max-width: 480px) ========== */
@media (max-width: 480px) {
    .main {
        padding: 16px 14px 80px 14px;
    }
    
    .card p {
        font-size: 26px;
    }
    
    .sidebar a {
        font-size: 10px;
        padding: 6px 2px;
    }
    
    .sidebar a::before {
        font-size: 18px;
    }
    
    .page-head h1, .page-head h2 {
        font-size: 24px;
    }
    
    .photo-card img {
        height: 180px;
    }
}

/* ========== ADDITIONAL MODERN TOUCHES ========== */
/* Smooth loading skeleton effect (optional) */
@keyframes subtlePulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* iOS-style inset safe area support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sidebar {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .main {
        padding-bottom: max(90px, calc(env(safe-area-inset-bottom) + 70px));
    }
}

/* Better focus outline for accessibility */
:focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
    border-radius: 12px;
}

/* Disable hover effects on touch devices for better performance */
@media (hover: none) {
    .card:hover,
    .photo-card:hover,
    .form-card:hover {
        transform: none;
    }
    .sidebar a:hover {
        transform: none;
        background: transparent;
    }
}

/* Ripple effect simulation for buttons (optional smooth press) */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:active::after {
    width: 200px;
    height: 200px;
    opacity: 0;
    transition: 0s;
}

/* Modern loading spinner alternative for any loading state (optional) */
.loading {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(245, 158, 11, 0.2);
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Ensure all cards have consistent spacing on all screen sizes */
.card, .form-card, .photo-card {
    transition: all 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

/* Additional glassmorphic effect for login and tables */
.login-card, .table-wrap {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
}

/* Improve dark/light readability */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(145deg, #121826, #0f111a);
        color: #eef2ff;
    }
    .card, .form-card, .table-wrap, .detail-card, .photo-card {
        background: rgba(30, 41, 59, 0.7);
        backdrop-filter: blur(12px);
        border-color: rgba(255, 255, 255, 0.08);
        color: #e2e8f0;
    }
    .card p {
        background: linear-gradient(145deg, #fbbf24, #f59e0b);
        -webkit-background-clip: text;
        background-clip: text;
    }
    .form-group input, .form-group select, .form-group textarea {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }
    .sidebar {
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(20px);
    }
    @media (min-width: 768px) {
        .sidebar {
            background: linear-gradient(180deg, #0b1120, #111827);
        }
    }
}

/* Important: Ensure meta viewport is added in HTML for proper scaling */
/* Add this to <head> if not present: 
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes, viewport-fit=cover"> 
*/

.link-delete {
    background: none;
    border: 0;
    color: #dc2626;
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}
.link-delete:hover {
    color: #991b1b;
}
