/*
 * CORPORATE INVOICE MANAGEMENT SYSTEM
 * Design System v1.0
 * 
 * Color Palette:
 * Primary Red:    #ee3233
 * Off White:      #fefaf7
 * Dark Text:      #252525
 * Soft Pink:      #d6646a
 * Alert Red:      #d74249
 * Light Pink:     #f9cbcd
 * Muted Rose:     #e29094
 * Neutral Gray:   #5b5b5a
 */

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #ee3233;
    --off-white: #fefaf7;
    --dark-text: #252525;
    --soft-pink: #d6646a;
    --alert-red: #d74249;
    --light-pink: #f9cbcd;
    --muted-rose: #e29094;
    --neutral-gray: #5b5b5a;
    
    --shadow-sm: 0 2px 8px rgba(37, 37, 37, 0.08);
    --shadow-md: 0 4px 16px rgba(37, 37, 37, 0.12);
    --shadow-lg: 0 8px 32px rgba(37, 37, 37, 0.16);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 20px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, var(--light-pink) 0%, var(--muted-rose) 100%);
    color: var(--dark-text);
    line-height: 1.6;
    min-height: 100vh;
    padding: var(--spacing-md);
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    color: var(--dark-text);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-sm);
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 20px;
}

h4 {
    font-size: 18px;
}

p {
    margin-bottom: var(--spacing-sm);
}

small {
    font-size: 13px;
    color: var(--neutral-gray);
}

/* ===== CONTAINER & LAYOUT ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-sm {
    max-width: 800px;
    margin: 0 auto;
}

.container-md {
    max-width: 1000px;
    margin: 0 auto;
}

/* ===== HEADER ===== */
.page-header {
    background: var(--off-white);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.page-header-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.page-header-title i {
    color: var(--primary-red);
    font-size: 28px;
}

.page-header-title h1 {
    margin: 0;
}

.page-header-subtitle {
    font-size: 14px;
    color: var(--neutral-gray);
    margin-top: 4px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-red);
    color: white;
}

.btn-primary:hover {
    background: #d82829;
}

.btn-secondary {
    background: var(--neutral-gray);
    color: white;
}

.btn-secondary:hover {
    background: #4a4a49;
}

.btn-outline {
    background: transparent;
    color: var(--dark-text);
    border: 2px solid var(--neutral-gray);
}

.btn-outline:hover {
    background: var(--neutral-gray);
    color: white;
}

.btn-success {
    background: var(--soft-pink);
    color: white;
}

.btn-danger {
    background: var(--alert-red);
    color: white;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== CARDS ===== */
.card {
    background: var(--off-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.card-header {
    border-bottom: 2px solid var(--light-pink);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark-text);
    margin: 0;
}

.card-body {
    padding: 0;
}

.card-footer {
    border-top: 2px solid var(--light-pink);
    padding-top: var(--spacing-md);
    margin-top: var(--spacing-lg);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* ===== GRID BOXES (Dashboard) ===== */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.grid-box {
    background: var(--off-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border-top: 4px solid var(--primary-red);
}

.grid-box:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.grid-box-number {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-sm);
}

.grid-box-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-red), var(--soft-pink));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.grid-box-icon i {
    font-size: 32px;
    color: white;
}

.grid-box-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark-text);
    margin-bottom: var(--spacing-sm);
}

.grid-box-description {
    font-size: 14px;
    color: var(--neutral-gray);
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.grid-box-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-red);
    font-weight: 600;
    font-size: 14px;
}

.grid-box-action i {
    transition: transform 0.3s ease;
}

.grid-box:hover .grid-box-action i {
    transform: translateX(5px);
}

/* ===== FORMS ===== */
.form-container {
    max-width: 900px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: var(--spacing-xs);
    font-size: 14px;
}

.form-label-required::after {
    content: ' *';
    color: var(--alert-red);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
    color: var(--dark-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(238, 50, 51, 0.1);
}

.form-control:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    font-size: 13px;
    color: var(--neutral-gray);
    margin-top: 4px;
}

.form-error {
    font-size: 13px;
    color: var(--alert-red);
    margin-top: 4px;
    display: block;
}

/* ===== FILE UPLOAD ===== */
.file-upload {
    position: relative;
}

.file-upload-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border: 2px dashed var(--neutral-gray);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.file-upload-label:hover {
    border-color: var(--primary-red);
    background: var(--off-white);
}

.file-upload-preview {
    margin-top: var(--spacing-sm);
    text-align: center;
}

.file-upload-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* ===== TABLES ===== */
.table-container {
    background: var(--off-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: linear-gradient(135deg, var(--light-pink), var(--muted-rose));
}

.table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-text);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--off-white);
}

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

.table-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-inactive {
    background: #ffebee;
    color: #c62828;
}

.badge-draft {
    background: #fff3e0;
    color: #e65100;
}

/* ===== ALERTS ===== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

.alert-error {
    background: #ffebee;
    color: var(--alert-red);
    border-left: 4px solid var(--alert-red);
}

.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border-left: 4px solid #ff9800;
}

.alert-info {
    background: var(--off-white);
    color: var(--dark-text);
    border-left: 4px solid var(--soft-pink);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
}

.empty-state-icon {
    font-size: 64px;
    color: var(--neutral-gray);
    margin-bottom: var(--spacing-md);
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: var(--spacing-sm);
}

.empty-state-text {
    font-size: 15px;
    color: var(--neutral-gray);
    margin-bottom: var(--spacing-md);
}

/* ===== STATS SECTION ===== */
.stats-section {
    background: var(--off-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.stat-card {
    background: linear-gradient(135deg, var(--off-white) 0%, #f8f8f8 100%);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
    border: 2px solid var(--light-pink);
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--neutral-gray);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    font-size: 14px;
}

.breadcrumb a {
    color: var(--neutral-gray);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-red);
}

.breadcrumb-separator {
    color: var(--neutral-gray);
}

.breadcrumb-current {
    color: var(--dark-text);
    font-weight: 600;
}

/* ===== ACTION BUTTONS ===== */
.action-buttons {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon-edit {
    background: var(--soft-pink);
    color: white;
}

.btn-icon-edit:hover {
    background: var(--primary-red);
}

.btn-icon-delete {
    background: var(--alert-red);
    color: white;
}

.btn-icon-delete:hover {
    background: #b71c1c;
}

.btn-icon-view {
    background: var(--neutral-gray);
    color: white;
}

.btn-icon-view:hover {
    background: var(--dark-text);
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

/* ===== LOADING ===== */
.loading {
    text-align: center;
    padding: var(--spacing-xl);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--light-pink);
    border-top-color: var(--primary-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
    }
    
    .page-header {
        padding: var(--spacing-md);
    }
    
    h1 {
        font-size: 24px;
    }
    
    .grid-container {
        grid-template-columns: 1fr;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: center;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.d-flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing-md); }

.w-100 {
    width: 100%;
}

/* ===== SECTION DIVIDER ===== */
.section-divider {
    border: none;
    border-top: 2px solid var(--light-pink);
    margin: var(--spacing-lg) 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--light-pink);
}

.section-header i {
    color: var(--primary-red);
    font-size: 20px;
}

.section-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--dark-text);
}

/* ===== GRID BOX HEIGHT FIX ===== */
.grid-box {
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.grid-box-description {
    flex-grow: 1;
}

/* ===== INVOICE SPECIFIC ===== */
.invoice-items-table {
    width: 100%;
    margin-bottom: var(--spacing-md);
}

.invoice-items-table td,
.invoice-items-table th {
    padding: var(--spacing-sm);
    vertical-align: middle;
}

.invoice-summary-card {
    background: linear-gradient(135deg, var(--off-white) 0%, #f8f8f8 100%);
    border: 2px solid var(--light-pink);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid #e0e0e0;
}

.invoice-summary-row:last-child {
    border-bottom: none;
}

.invoice-summary-row.total {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-red);
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-md);
    border-top: 2px solid var(--primary-red);
}

.amount-in-words {
    background: var(--light-pink);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-top: var(--spacing-sm);
    font-style: italic;
    color: var(--dark-text);
}

/* ===== BETTER FORM SECTIONS ===== */
.form-section {
    margin-bottom: var(--spacing-xl);
}

.form-section:last-child {
    margin-bottom: 0;
}
