@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --ipm-primary: #00B1A9; /* Tosca */
    --ipm-secondary: #F2C94C; /* Yellow */
    --ipm-dark: #1F2937;
    --bg-light: #F9FAFB;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.6;
}

/* Islamic Pattern Background (Subtle) */
.bg-islamic {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2300b1a9' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Add pattern to body by default */
body {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2300b1a9' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

input, select, textarea, button {
    font-family: inherit;
}

/* Utilities */
.text-primary-ipm { color: var(--ipm-primary); }
.bg-primary-ipm { background-color: var(--ipm-primary); color: white; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary, .btn-primary-ipm {
    background-color: var(--ipm-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 177, 169, 0.2);
}

.btn-primary:hover, .btn-primary-ipm:hover {
    background-color: #008f88;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 177, 169, 0.3);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-ghost:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.btn-google {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-google-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-google-icon img {
    width: 100%;
    height: 100%;
}

/* Layout */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.app-header-left, .app-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-more-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: white;
    font-size: 20px;
    line-height: 1;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 58px;
    right: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    min-width: 200px;
    z-index: 1000;
}
.mobile-menu.open { display: block; }
.mobile-menu-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
}
.mobile-menu-item:last-child { border-bottom: none; }

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    object-fit: cover;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(0, 177, 169, 0.2);
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.app-body {
    display: flex;
    flex: 1;
    padding: 2rem;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: white;
    padding: 1.5rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar-link:hover {
    color: var(--ipm-primary);
    background-color: rgba(0, 177, 169, 0.05);
}

.sidebar-link-active, .nav-link.active {
    color: var(--ipm-primary) !important;
    font-weight: 700;
    background-color: rgba(0, 177, 169, 0.1);
}

/* Page Content */
.page {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0; /* Prevent grid blowout */
}

.page-content {
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
    font-weight: 700;
    color: var(--text-main);
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Cards & Panels */
.card-custom, .panel, .stat-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
    overflow: hidden;
}

.card-custom:hover, .panel:hover, .stat-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.panel-body {
    padding: 1.5rem;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.panel-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

/* Stats */
.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: clamp(1.25rem, 2vw, 1.6rem);
    font-weight: 700;
    color: var(--text-main);
}

.stat-chip {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    align-self: flex-start;
}

.stat-chip-primary { background: rgba(0, 177, 169, 0.1); color: var(--ipm-primary); }
.stat-chip-secondary { background: rgba(242, 201, 76, 0.15); color: #d97706; }
.stat-chip-warning { background: rgba(249, 115, 22, 0.15); color: #c2410c; }
.stat-chip-success { background: rgba(34, 197, 94, 0.15); color: #15803d; }

/* Forms */
.form-grid {
    display: grid;
    gap: 1.5rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-field input, .form-field select, .form-field textarea {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #F9FAFB;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none;
    border-color: var(--ipm-primary);
    box-shadow: 0 0 0 3px rgba(0, 177, 169, 0.1);
    background: white;
}

.form-field-inline {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table-wide {
    min-width: 900px;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-break: break-word;
}

.table th {
    background: #F9FAFB;
    font-weight: 600;
    color: var(--text-muted);
}

.table tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-status-pending { background: #FEF3C7; color: #92400E; }
.badge-status-diterima { background: #DCFCE7; color: #166534; }
.badge-status-ditolak { background: #FEE2E2; color: #991B1B; }

/* Loader */
.loader-overlay, #loader {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s;
}

.loader-spinner, .spinner-ipm {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--ipm-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Auth Page */
.page-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 3rem;
    padding: 3rem;
    max-width: 1000px;
    width: 100%;
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.auth-hero h1 {
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    font-weight: 800;
    color: var(--ipm-primary);
    margin-bottom: 0.5rem;
}

@media (max-width: 1200px) {
    .app-body {
        padding: 1.5rem;
        gap: 1.5rem;
    }
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .app-body {
        padding: 1rem;
        gap: 1rem;
    }
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .panel-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .table {
        font-size: 0.85rem;
    }
    .table th, .table td {
        padding: 0.75rem;
    }
}

/* Mobile & Responsive */
@media (max-width: 960px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .app-header-right {
        width: 100%;
        justify-content: space-between;
    }
    .app-body {
        flex-direction: column;
        padding: 1rem;
    }
    .sidebar {
        width: 100%;
        overflow-x: auto;
    }
    .sidebar-nav {
        flex-direction: row;
        width: max-content;
    }
    .panel-row {
        grid-template-columns: 1fr;
    }
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .auth-card {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 640px) {
    .app-header {
        flex-direction: row;
        align-items: center;
        padding: 0.8rem 1rem;
        position: sticky;
        top: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        z-index: 50;
        border-bottom: 1px solid var(--border-color);
    }

    .brand-subtitle, .user-name, .user-role {
        display: none;
    }

    .brand-logo { width: 32px; height: 32px; }
    .brand-title { font-size: 1.1rem; }
    
    .app-body {
        padding: 0;
        padding-bottom: 5rem;
        gap: 0;
    }
    
    .page-header h1 {
        font-size: 1.1rem;
    }

    .sidebar { display: none; }

    .page-content {
        padding: 1rem;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }

    .grid-4 { grid-template-columns: 1fr; }

    .bottom-nav {
        display: none;
    }

    .bottom-nav-item {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-muted);
        padding: 0.8rem;
        border-radius: 0.5rem;
        flex: 1;
        transition: all 0.2s;
    }

    .bottom-nav-icon {
        width: 22px;
        height: 22px;
        stroke-width: 1.8;
    }

    .bottom-nav-item.active {
        color: var(--ipm-primary);
        background: rgba(0, 177, 169, 0.1);
    }

    .app-footer { display: none; }
    
    .btn { width: 100%; }
    
    .form-field-inline { grid-template-columns: 1fr; }
    
    .table th, .table td { padding: 0.5rem; font-size: 0.8rem; }
    .table-wide { min-width: 680px; }
    
    .mobile-more-btn { display: inline-flex; align-items: center; justify-content: center; }
}

@media (min-width: 641px) {
    .bottom-nav { display: none; }
}
