/* ============================================
   Azma Finance Invoice Generator
   Premium Mobile-First Design System
   ============================================ */

/* ========== CSS Variables (Design Tokens) ========== */
:root {
    /* Azma Brand Colors */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --primary-glow: rgba(37, 99, 235, 0.15);

    --secondary: #06b6d4;
    --secondary-dark: #0891b2;

    --accent: #8b5cf6;
    --accent-dark: #7c3aed;

    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px var(--primary-glow);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ========== Reset & Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    color: var(--gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ========== Typography ========== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

/* ========== Container & Layout ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-md);
}

.header {
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
    margin-bottom: var(--space-xl);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: var(--radius-xl);
}

.header__subtitle {
    color: var(--gray-600);
    margin-top: var(--space-sm);
    font-size: 1.125rem;
}

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-xl);
    border: 1px solid var(--gray-200);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

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

.card__header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--gray-100);
}

.card__title {
    font-size: 1.5rem;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ========== Form Elements ========== */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

@media (min-width: 768px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }

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

label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.label__required {
    color: var(--error);
    margin-left: var(--space-xs);
}

input[type="text"],
input[type="number"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--gray-900);
    background: var(--white);
    transition: all var(--transition-normal);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

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

.input-icon-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.input-icon-wrapper input {
    padding-left: 2.5rem;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

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

.btn--secondary {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn--success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: var(--white);
}

.btn--danger {
    background: var(--gray-200);
    color: var(--error);
}

.btn--danger:hover {
    background: var(--error);
    color: var(--white);
}

.btn--large {
    padding: var(--space-lg) var(--space-2xl);
    font-size: 1.125rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-group {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ========== Table Styles ========== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

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

thead {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

th {
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--gray-200);
}

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

tbody tr {
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background-color: var(--gray-50);
}

/* ========== Items Cards (Modern Design) ========== */
.items-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.item-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
}

.item-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.item-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--gray-100);
}

.item-card__number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.875rem;
}

.item-card__remove {
    background: none;
    border: none;
    padding: var(--space-sm);
    cursor: pointer;
    color: var(--gray-400);
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
}

.item-card__remove:hover {
    background: var(--error);
    color: var(--white);
}

.item-card__body {
    display: grid;
    gap: var(--space-md);
}

.item-card__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

@media (max-width: 768px) {
    .item-card__row {
        grid-template-columns: 1fr;
    }
}

.item-card__field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.item-card__field--full {
    grid-column: 1 / -1;
}

.item-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.item-card__total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 2px solid var(--gray-100);
}

.item-card__total-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.item-card__total-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-mono);
}

/* Hide old table styles */
.table-wrapper {
    display: none;
}

.items-table {
    display: none;
}

/* ========== INN Status Styles ========== */
.inn-status {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: var(--space-sm);
}

.inn-status--success {
    background: var(--success);
    color: var(--white);
}

.inn-status--error {
    background: var(--error);
    color: var(--white);
}

.inn-status--loading {
    background: var(--info);
    color: var(--white);
}

/* ========== Totals Section ========== */
.totals-section {
    max-width: 400px;
    margin-left: auto;
    margin-top: var(--space-xl);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) 0;
    font-size: 1rem;
}

.totals-row__label {
    color: var(--gray-600);
}

.totals-row__value {
    font-weight: 600;
    color: var(--gray-900);
}

.totals-row--grand {
    border-top: 2px solid var(--primary);
    margin-top: var(--space-md);
    padding-top: var(--space-lg);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* ========== Alerts & Messages ========== */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.alert--success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: #065f46;
}

.alert--error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: #991b1b;
}

.alert--info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--info);
    color: #1e3a8a;
}

/* ========== Loading Spinner ========== */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.azma-branding {
    margin-top: var(--space-xl);
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: var(--radius-lg);
}

.azma-branding__text {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
}

.azma-branding__cta {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.azma-branding__cta:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ========== Utility Classes ========== */
.hidden {
    display: none !important;
}

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

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

.mt-auto {
    margin-top: auto !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.gap-md {
    gap: var(--space-md);
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: var(--space-lg);
    }

    .table-wrapper {
        margin: 0 calc(-1 * var(--space-md));
    }

    th,
    td {
        padding: var(--space-sm);
        font-size: 0.875rem;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ========== Supplier Toggle Styles ========== */
.supplier-toggle {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.supplier-btn {
    flex: 1;
    min-width: 150px;
    padding: var(--space-md) var(--space-lg);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-600);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.supplier-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.supplier-btn--active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: var(--white);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.supplier-btn--active:hover {
    color: var(--white);
}

/* Supplier Info Card */
.supplier-info {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-top: var(--space-md);
}

.supplier-info__company {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-md);
}

.supplier-info__details {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    color: var(--gray-600);
    font-size: 0.9rem;
}

.supplier-info__details div {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Custom Supplier Form Animation */
.custom-supplier-form {
    margin-top: var(--space-lg);
    animation: fadeIn var(--transition-normal) ease-out;
}