@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(20, 26, 45, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #10b981;
    --accent-primary-hover: #059669;
    --accent-secondary: #6366f1;
    --accent-secondary-hover: #4f46e5;
    --danger: #f43f5e;
    --danger-hover: #e11d48;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #1e1b4b, #0b0f19 60%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Dashboard Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #10b981 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-section span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex-grow: 1;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar / Left Column */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-left: 3px solid var(--accent-primary);
    padding-left: 0.5rem;
}

/* Dropzone Styles */
.dropzone-container {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
}

.dropzone-container:hover {
    border-color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.05);
}

.dropzone-container svg {
    width: 48px;
    height: 48px;
    fill: var(--text-secondary);
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.dropzone-container:hover svg {
    transform: translateY(-5px);
    fill: var(--accent-primary);
}

.dropzone-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.dropzone-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

/* List group */
.statement-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.statement-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.statement-item:hover, .statement-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-secondary);
}

.statement-item .info {
    flex-grow: 1;
    min-width: 0;
}

.statement-item .party-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.statement-item .details {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    stroke: rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

/* Metadata Forms */
.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Table styles */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: rgba(15, 23, 42, 0.8);
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

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

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

/* Nested Items Editor Table */
.items-nested-row {
    background: rgba(0, 0, 0, 0.2);
}

.items-nested-cell {
    padding: 0.5rem 1.5rem 1.5rem 1.5rem;
}

.items-editor-container {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
}

.items-table {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.items-table th {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0.75rem;
}

.items-table td {
    padding: 0.5rem 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    border: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
}

.btn-secondary {
    background: var(--accent-secondary);
    color: #ffffff;
}

.btn-secondary:hover {
    background: var(--accent-secondary-hover);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-xs {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Header toolbar buttons */
.toolbar {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-danger {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fb7185;
}

/* Collapse/Expand details button */
.btn-expand {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.btn-expand.expanded {
    transform: rotate(90deg);
}

/* Input sizes inside tables */
.table-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.table-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Dropdown list txn type styling */
select.table-input {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 16px;
    padding-right: 20px;
}

/* Total highlights */
.total-summary-card {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.total-summary-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* =============================================
   MOBILE RESPONSIVE STYLES
   ============================================= */

/* Tablet and below (max 1024px) */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 280px 1fr;
        gap: 1rem;
        padding: 1rem;
    }
}

/* Mobile (max 768px) - Stack sidebar above content */
@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .logo-section h1 {
        font-size: 1.2rem;
    }

    .logo-section span {
        font-size: 0.7rem;
    }

    /* Stack layout vertically on mobile */
    .dashboard-layout {
        grid-template-columns: 1fr;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .sidebar {
        gap: 0.75rem;
    }

    /* Limit statement list height on mobile */
    .statement-list {
        max-height: 250px;
    }

    /* Card padding reduction */
    .card {
        padding: 1rem;
        border-radius: 12px;
    }

    .card-title {
        font-size: 1rem;
    }

    /* Editor header - stack buttons below title on mobile */
    #editorCard > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    #editorCard > div:first-child > div {
        width: 100%;
        justify-content: stretch;
    }

    #editorCard > div:first-child .btn {
        flex: 1;
        justify-content: center;
    }

    /* Metadata grid - 1 column on mobile */
    .metadata-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    /* Toolbar - full width buttons */
    .toolbar {
        flex-wrap: wrap;
    }

    .toolbar .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }

    /* Table - horizontal scroll on mobile */
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }

    table {
        min-width: 550px;
        font-size: 0.82rem;
    }

    th, td {
        padding: 0.6rem 0.75rem;
        white-space: nowrap;
    }

    /* Items nested table */
    .items-nested-cell {
        padding: 0.5rem 0.75rem 0.75rem 0.75rem;
    }

    .items-table {
        min-width: 480px;
    }

    /* Buttons - slightly larger touch targets */
    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
    }

    /* Statement items */
    .statement-item {
        padding: 0.65rem 0.75rem;
    }

    .statement-item .party-name {
        font-size: 0.88rem;
    }

    /* Empty state */
    .empty-state {
        padding: 3rem 1rem;
    }

    /* Total summary card - stack on mobile */
    .total-summary-card {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        padding: 0.75rem 1rem;
    }
}

/* Very small phones (max 480px) */
@media (max-width: 480px) {
    header {
        padding: 0.6rem 0.75rem;
    }

    .logo-section h1 {
        font-size: 1.05rem;
    }

    .dashboard-layout {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .card {
        padding: 0.75rem;
        border-radius: 10px;
    }

    /* Metadata - single column on very small screens */
    .metadata-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 0.6rem 0.85rem;
        font-size: 0.82rem;
    }

    .btn-xs {
        padding: 0.35rem 0.65rem;
        font-size: 0.72rem;
    }

    table {
        font-size: 0.78rem;
    }

    th, td {
        padding: 0.5rem 0.6rem;
    }

    .statement-list {
        max-height: 180px;
    }

    .dropzone-container {
        padding: 1.5rem 0.75rem;
    }

    .dropzone-container svg {
        width: 36px;
        height: 36px;
    }

    .dropzone-text {
        font-size: 0.82rem;
    }
}

/* Mobile upload button - hidden on desktop, visible on mobile */
.mobile-upload-btn {
    display: none;
}

@media (max-width: 768px) {
    .mobile-upload-btn {
        display: flex;
        width: 100%;
        margin-top: 0.75rem;
        justify-content: center;
        font-size: 0.95rem;
        padding: 0.85rem 1rem;
        border-radius: 10px;
        gap: 0.5rem;
    }

    /* Make dropzone a bit taller on mobile for easier tapping */
    .dropzone-container {
        padding: 1.5rem 1rem;
        min-height: 110px;
    }
}
