/* Global Reset & Base Styles */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --text-main: #1f2937;
    /* Slightly darker for contrast on glass */
    --text-muted: #4b5563;
    --border: rgba(255, 255, 255, 0.4);
    --radius: 16px;
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    /* Mesh Gradient Background */
    background: radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-color: #111827;
    /* Fallback/Base Dark */
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 2rem;
    min-height: 100vh;
}

/* App Container - The Main Glass Panel */
.app-container {
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    /* Added top margin */
    min-height: 90vh;

    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-glass);
    border-radius: var(--radius);

    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* For radius clipping */
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.4);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-area i {
    -webkit-text-fill-color: #4f46e5;
    /* Reset icon color */
    font-size: 1.2rem;
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    background: #d1fae5;
    color: #065f46;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
}

.upload-btn {
    font-size: 0.875rem;
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.upload-btn:hover {
    transform: translateY(-2px);
    background: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Search Bar */
.search-sticky {
    position: sticky;
    top: 73px;
    /* Header height approx */
    z-index: 40;
    background: rgba(255, 255, 255, 0.6);
    padding: 1rem 1.5rem;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 3rem;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

/* Device List */
.device-list {
    padding: 1.5rem;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 1.5rem 0;
    font-size: 2rem;
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.btn-primary {
    margin-top: 1.5rem;
    padding: 0.8rem 1.8rem;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    border: none;
    color: white;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(79, 70, 229, 0.4);
}

/* Device Card - Glass Card */
.device-card {
    background: rgba(255, 255, 255, 0.45);
    /* More transparent */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.device-card:hover {
    background: rgba(255, 255, 255, 0.65);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    /* Deeper shadow on hover */
}

.card-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.vehicle-number {
    font-size: 1.25rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tags {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    background: rgba(239, 246, 255, 0.7);
    color: #1d4ed8;
    text-transform: uppercase;
    border: 1px solid rgba(29, 78, 216, 0.1);
}

.model-badge {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(168, 85, 247, 0.15));
    border: 1px solid rgba(79, 70, 229, 0.15);
    color: #4f46e5;
}

.sim-info {
    font-size: 0.85rem;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Actions */
.actions {
    display: flex;
    gap: 0.6rem;
}

.reset-btn,
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.reset-btn {
    background: rgba(254, 226, 226, 0.8);
    color: #dc2626;
}

.reset-btn:hover {
    background: #fee2e2;
    transform: rotate(90deg);
}

.edit-btn {
    background: rgba(254, 243, 199, 0.8);
    color: #d97706;
}

.edit-btn:hover {
    background: #fef3c7;
    transform: translateY(-2px);
}

.delete-btn {
    background: rgba(243, 244, 246, 0.8);
    color: #4b5563;
}

.delete-btn:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
    color: #ef4444;
}

.status-btn {
    background: rgba(219, 234, 254, 0.8);
    color: #2563eb;
}

.status-btn:hover {
    background: #dbeafe;
    transform: translateY(-2px);
}


/* Card Details */
.card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 0.85rem;
    font-size: 0.8rem;
    color: #6b7280;
    font-family: 'Courier New', monospace;
    /* Tech feel */
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

.status-inactive {
    background: #9ca3af;
    box-shadow: none;
}

@keyframes blinkYellow {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.status-expiring-soon {
    background: #eab308;
    box-shadow: 0 0 8px #eab308;
    animation: blinkYellow 1s infinite;
}

.hidden {
    display: none !important;
}

/* Modals - Glass Panels */
.modal-overlay {
    background: rgba(0, 0, 0, 0.2);
    /* Lighter backdrop */
    backdrop-filter: blur(5px);
}

.modal-content {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border-radius: 20px;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.5);
    /* Semi transparent */
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    position: sticky;
    bottom: 0;
    z-index: 40;
}

.pagination-btn {
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.2s;
    font-weight: 500;
}

.pagination-btn:hover:not(:disabled) {
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
    color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f3f4f6;
}

#page-indicator {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Form Grid Layout */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4b5563;
    padding-left: 4px;
}

.form-input {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-left-width: 5px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUpFade 0.3s forwards;
    pointer-events: auto;
}

.toast.success {
    border-color: #10b981;
}

.toast.error {
    border-color: #ef4444;
}

.toast i {
    font-size: 1.25rem;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutDown {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* List Item Animation */
.new-item-anim {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        background-color: rgba(255, 255, 255, 0.9);
        transform: scale(1.02);
    }

    100% {
        background-color: var(--card-bg);
        transform: scale(1);
    }
}

/* SIM Container Support */
.sim-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sim-row {
    font-size: 0.8rem;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.icon-btn-sm {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #6b7280;
    opacity: 0.6;
    padding: 2px;
    font-size: 0.8rem;
    margin-left: 4px;
}

.icon-btn-sm:hover {
    opacity: 1;
    color: var(--primary);
}

/* --- RESPONSIVE LAYOUT ADJUSTMENTS --- */

/* Mobile (< 640px) */
@media (max-width: 640px) {
    .app-container {
        width: 100%;
        margin: 0;
        min-height: 100vh;
        /* Full height */
        border-radius: 0;
        /* No corners */
        background: rgba(255, 255, 255, 0.9);
        /* Higher opacity */
    }

    .device-list {
        grid-template-columns: 1fr;
        /* Single column */
        padding: 1rem;
        gap: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .logo-area {
        font-size: 1.25rem;
    }
}

/* Small Mobile (< 480px) - Header Stacking */
@media (max-width: 480px) {
    .app-header {
        flex-direction: column;
        gap: 0.75rem;
        padding-bottom: 1rem;
    }

    .logo-area {
        width: 100%;
        justify-content: center;
    }

    .controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .search-sticky {
        top: 105px;
        /* Adjusted */
        padding: 0.75rem 1rem;
    }

    .pagination-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .pagination-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Laptop/Desktop Optimizations (> 1024px) */
@media (min-width: 1024px) {
    .app-container {
        max-width: 1100px;
        /* Refined width */
    }

    .device-list {
        gap: 2rem;
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        /* Slightly wider cards */
    }
}

/* Large Screens (> 1440px) */
@media (min-width: 1440px) {
    .app-container {
        max-width: 1300px;
    }
}