/* ABJAD GURU - Unified Responsive Design (Mobile First + Desktop) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --info: #4299e1;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --header-height: 70px;
    --navbar-height: 70px;
    --safe-area-bottom: max(0px, env(safe-area-inset-bottom));
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   CONTAINER LAYOUT
   ======================================== */

.abjad-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: var(--gray-50);
}

.abjad-app > div:not(.abjad-navbar) {
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ========================================
   HEADER
   ======================================== */

.abjad-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    z-index: 100;
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 12px 0;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-filter {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
}

.header-filter input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    font-size: 14px;
}

.header-filter input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.header-btn {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.header-btn:active {
    background: rgba(255, 255, 255, 0.5);
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.abjad-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.tab-content {
    display: none;
    padding: 16px;
    min-height: 100%;
}

.tab-content.active {
    display: block;
}

.tab-header {
    margin-bottom: 20px;
}

.tab-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

/* ========================================
   CARDS & LISTINGS
   ======================================== */

.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 16px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.card:active {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--gray-800);
}

.card-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

.card-date {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 8px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.grid-item {
    background: white;
    border-radius: var(--border-radius);
    padding: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: var(--transition);
}

.grid-item:active {
    transform: scale(0.98);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.grid-item-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.grid-item-label {
    font-size: 12px;
    color: var(--gray-600);
    margin: 8px 0 0 0;
}

/* ========================================
   LIST ITEMS
   ======================================== */

.list-item {
    background: white;
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: var(--transition);
}

.list-item:active {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--gray-500);
    margin: 4px 0 0 0;
}

.list-item-icon {
    font-size: 24px;
    margin-left: 12px;
}

/* ========================================
   BOTTOM NAVBAR
   ======================================== */

.abjad-navbar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: white;
    border-top: 1px solid var(--gray-200);
    height: var(--navbar-height);
    padding-bottom: var(--safe-area-bottom);
    position: sticky;
    bottom: 0;
    z-index: 1000;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px;
    color: var(--gray-400);
    text-decoration: none;
    transition: var(--transition);
    border: none;
    background: transparent;
    cursor: pointer;
}

.nav-item:active {
    color: var(--primary);
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* ========================================
   FLOATING ACTION BUTTON
   ======================================== */

.fab-button {
    position: fixed;
    bottom: calc(var(--navbar-height) + var(--safe-area-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    font-size: 28px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: var(--transition);
}

.fab-button:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.fab-button.active {
    display: flex;
}

/* ========================================
   MODALS
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    align-items: flex-end;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-fullscreen {
    background: white;
    width: 100%;
    height: 80vh;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    max-height: 90vh;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.modal-header button {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:active {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:active {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:active {
    opacity: 0.9;
}

/* ========================================
   STATS & BADGES
   ======================================== */

.stat-badge {
    display: inline-block;
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.stat-badge.success {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success);
}

.stat-badge.warning {
    background: rgba(237, 137, 54, 0.1);
    color: var(--warning);
}

.stat-badge.danger {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger);
}

/* ========================================
   LOADING & EMPTY STATES
   ======================================== */

.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 60px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 8px 0;
}

.empty-text {
    font-size: 14px;
    color: var(--gray-500);
    margin: 0;
}

/* ========================================
   BOTTOM SPACER
   ======================================== */

.bottom-safe-spacer {
    height: calc(var(--navbar-height) + var(--safe-area-bottom));
    flex-shrink: 0;
}

/* ========================================
   DESKTOP VERSION (Min-width: 768px)
   ======================================== */

@media (min-width: 768px) {
    .abjad-navbar {
        display: none;
    }

    .fab-button {
        display: none !important;
    }

    .abjad-header {
        padding: 20px;
    }

    .app-title {
        font-size: 28px;
        margin-bottom: 16px;
    }

    .abjad-main {
        padding: 0;
    }

    .tab-content {
        padding: 40px;
        max-width: 1200px;
        margin: 0 auto;
    }

    .grid-2col {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

    .modal-fullscreen {
        width: 80%;
        height: auto;
        max-width: 500px;
        border-radius: var(--border-radius);
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .modal-overlay {
        align-items: center;
        justify-content: center;
    }
}
